package com.dlyk.service.impl;

import com.dlyk.constant.Constants;
import com.dlyk.mapper.TDicValueMapper;
import com.dlyk.model.TDicType;
import com.dlyk.model.TDicValue;
import com.dlyk.query.BaseQuery;
import com.dlyk.service.DicValueService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description:
 * @author: ajie
 * @date: 2024/8/17 15:38:15
 * @version: 1.0
 */
@Service
public class DicValueServiceImpl implements DicValueService {

    @Resource
    private TDicValueMapper tDicValueMapper;

    @Override
    public PageInfo<TDicValue> getDicValueByPage(Integer current,TDicValue tDicValue) {
        //设置PageHelper的分页参数
        PageHelper.startPage(current, Constants.PAGE_SIZE);
        //查询
        List<TDicValue> list = tDicValueMapper.selectDicValueByPage(tDicValue);
        //封装分页参数到PageInfo
        PageInfo<TDicValue> info = new PageInfo<>(list);
        return info;
    }

    @Override
    public TDicValue getDicValueById(Integer id) {
        return tDicValueMapper.selectByPrimaryKey(id);
    }

    @Override
    public int saveDicValue(TDicValue tDicValue) {
        return tDicValueMapper.insertSelective(tDicValue);
    }

    @Override
    public int updateDicValue(TDicValue tDicValue) {
        return tDicValueMapper.updateByPrimaryKeySelective(tDicValue);
    }

    @Override
    public int delDicValueById(Integer id) {
        return tDicValueMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int batchDelDicValueByIds(List<String> idList) {
        return tDicValueMapper.deleteByIds(idList);
    }

    @Override
    public List<TDicValue> getSourceByAll() {
        return null;
    }
}
